package LeetCode;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}13:47
 */
public class LeetCode328 {

    public class ListNode {
        int val;
        ListNode next;
        ListNode(int x) { val = x; }
    }
    public ListNode oddEvenList(ListNode head) {
       if (head == null){
           return null;
       }
       ListNode odd = head;
       ListNode even = head.next;
       ListNode evenList = even;
       while (even != null || even.next != null){
           odd.next = even.next;
           odd = odd.next;
           even.next = odd.next;
           even = even.next;
       }
       odd.next = evenList;
       return head;
    }
}
